Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WiFiManager to 2.0.17 and add option to connect to strongest BSSID #349

Merged
merged 9 commits into from
May 22, 2024

Conversation

iranl
Copy link
Collaborator

@iranl iranl commented May 3, 2024

Add a solution for multi AP/Mesh environments where Nuki Hub connects to a random AP instead of the AP with the strongest signal and might be repeatedly kicked of the network by Mesh systems employing access point steering.

Fixes #348

Enable Connect to AP with the best signal in an environment with multiple APs with the same SSID in Advanced MQTT and Network Configuration to enable this new behaviour.

Binaries for testing:
esp32dev-assets.zip
esp32-s3-assets.zip
esp32-c3-assets.zip
esp32solo1-assets.zip

@jolichter: Can you test if this solves your WiFi issues? Note that this binary does not include the authName fixes.

@iranl iranl mentioned this pull request May 3, 2024
@jolichter
Copy link

jolichter commented May 3, 2024

Hi, the first try seems good. After updating and restarting, my ESP32-S3 connected to my nearby router, which has the strongest signal (-43dBm). This was a new experience, as the Nuki Hub had previously always connected to the first available AP instead of the one with the best signal.

I will continue watching and testing it. Can you maybe also add the authName fix for further testing, please?

Thank you very much!

PS: Also a second try to bring the AP temporarily closer to the ESP32 also worked.

@jolichter
Copy link

Yesterday evening, it was probably just luck. I have just made another attempt by placing the ESP32 next to an AP and turning the ESP32 on and off. After three tries, the ESP32 didn't connect to the AP, but instead connected to a more distant router or another AP (so far, there have been no authName errors).

System Information:

Nuki Hub version: 8.33
run: true
confVersion: 833
deviceId: 439958162
deviceIdOp: 439958162
nukiId: ***
nukidOp: 
mqttbroker: 192.168.2.164
mqttport: 1883
mqttuser: ***
mqttpass: ***
mqttlog: false
checkupdates: false
lockena: true
lockpin: 1
mqttpath: nuki
openerena: false
openerpin: 
openercont: false
mqttoppath: 
maxkpad: 
opmaxkpad: 
mqttca: 
mqttcrt: 
mqttkey: 
hassdiscovery: 
hassConfigUrl: 
dhcpena: false
ipaddr: 192.168.2.188
ipsub: 255.255.255.0
ipgtw: 192.168.2.1
dnssrv: 
nwhw: 1
nwwififb: false
rssipb: 60
nwbestrssi: true
hostname: nukihub
nettmout: 240
restdisc: true
rstbcn: 60
lockStInterval: 1800
configInterval: 3600
batInterval: 1800
kpInterval: 1800
kpCntrlEnabled: true
aclConfig: false
kpInfoEnabled: false
aclLckOpn: 
tcCntrlEnabled: false
tcInfoEnabled: false
accLvl: 
regAsApp: false
nrRetry: 3
rtryDelay: 100
crdusr: ***
crdpass: ***
pubAuth: false
pubdbg: false
prdtimeout: 60
hasmac: false
macb0: 
macb1: 
macb2: 
latest: 
MQTT connected: Yes
Lock firmware version: 3.9.5
Lock hardware version: 5.12
Lock paired: Yes
Lock PIN set: Yes
Lock has door sensor: No
Lock has keypad: No
Lock ACL (Lock): Allowed
Lock ACL (Unlock): Disallowed
Lock ACL (Unlatch): Disallowed
Lock ACL (Lock N Go): Disallowed
Lock ACL (Lock N Go Unlatch): Disallowed
Lock ACL (Full Lock): Disallowed
Lock ACL (Fob Action 1): Disallowed
Lock ACL (Fob Action 2): Disallowed
Lock ACL (Fob Action 3): Disallowed
Network device: Built-in Wi-Fi
Uptime: 5 minutes
Heap: 158736
Stack watermarks: nw: 5756, nuki: 276, pd: 92
Restart reason FW: NotApplicable
Restart reason ESP: ESP_RST_POWERON: Reset due to power-on event.

@iranl
Copy link
Collaborator Author

iranl commented May 4, 2024

You do seem to have it configured correctly so this will need some more debugging on my end.

@jolichter
Copy link

jolichter commented May 4, 2024

It seems as you mentioned that ESP's only connect to the first BSSID/AP they find and not necessarily the best one. An ESP with a LAN connection is unfortunately not possible in my place (too far away because of BLE).

I hope you can find a solution when debugging. I would be happy to test other firmwares with my test ESP32-S3.

btw: Does it also make sense to talk via Discord? The link under "About" seems to have expired. Otherwise I prefer Matrix (e.g. Element), where I have created a Nuki-Hub room: #nuki-hub:tchncs.de

@technyon
Copy link
Owner

technyon commented May 4, 2024

Hi, this is the link to our discord:

https://discord.gg/24HxpGBJ

@iranl iranl force-pushed the update-wifimanager branch 4 times, most recently from 65ba3b4 to 2d93af0 Compare May 4, 2024 18:48
@iranl
Copy link
Collaborator Author

iranl commented May 4, 2024

This one should work: esp32-s3-assets.zip

In the first version best BSSID was only selected on the very first connection to the network and not on every connection after (including after restarts). This is now fixed.

Tested with debugging enabled (off again in this binary) on my own ESP32-S3. With debugging on the BSSID selection process can be followed and in my testing worked perfectly.

The currently selected BSSID can also be viewed on the info page in the web configurator now.

@jolichter
Copy link

Yes, indeed, your second version works great!! I placed the ESP32-S3 near three different APs, and the Nuki-Hub connected to them as expected because it provides the best signal.

On the info page I can see the MAC BSSID of the AP for verification. I like that, thank you very much!

@alexdelprete
Copy link
Collaborator

@iranl could you share a version of this to test that is in par with 8.34 just released?

Amazing work. Thanks a lot.

@iranl
Copy link
Collaborator Author

iranl commented May 11, 2024

Binaries of current master (8.34 + #343) + this PR:

esp32-assets.zip
esp32-s3-assets.zip
esp32-c3-assets.zip
esp32solo1-assets.zip

@alexdelprete
Copy link
Collaborator

alexdelprete commented May 11, 2024

@iranl my observations/questions:

  1. does ESP32 support 802.11r for AP roaming?
    (update: it seems it does, see here)
  2. I would call the option "Enable/Disable AP Roaming".
  3. Would it make sense to implement a configurable RSSI threshold so user decides when to trigger the roaming. Without that, in specific cases the risk is that it bounces back and forth between 2 APs that have similar RSSIs that fluctuate.

@iranl
Copy link
Collaborator Author

iranl commented May 11, 2024

  1. I believe 802.11r was added to ESP-IDF in v5. As Arduino Core 2.0.15 is based on ESP-IDF v4.4.7 I don't believe 802.11r is currently supported
  2. It's not really a roaming option. Before this PR Nuki Hub just connected to the first AP it encounters that broadcasts the configured SSID. This could randomly be a very far AP with a bad signal or a very near AP with a good signal. It would not check for additional available AP's and it would not necessarily connect to the strongest AP. This option changes that behaviour and check for multiple AP's before selecting the one with the strongest signal and connect to that and stay connected to that until the connection is lost.. I would say this is perfectly fine for the use case of Nuki Hub. It's a static device and so are the AP's. There is no real reason for 802.11r in this case.
  3. See 2., there is no risk of this as Nuki Hub only connects to the strongest available AP at the time of connection and will stay connected to this AP until it loses this connection completely (e.g. because of the WIFI stack failing or the AP rebooting/shutdown). Your other config settings will determine if Nuki Hub will reboot at this time and reconnect or try to reconnect without rebooting. In both cases it will look for the strongest AP again and connect to that.

@alexdelprete
Copy link
Collaborator

2. This option changes that behaviour and check for multiple AP's before selecting the one with the strongest signal and connect to that and stay connected to that until the connection is lost

Ok, I thought it constantly checked for the AP with the strongest signal, so it only does it on connection, and obviously when it needs to reconnect (reboots, etc.), correct? It doesn't search for strongest signal when already connected.

@technyon
Copy link
Owner

Yes, WifiManager is only active during the connection phase, and then quits. It's a frontend to configure the ESPs Wifi stack, whatever else is handled within the stack.

@iranl iranl added this to the 8.35 milestone May 17, 2024
@iranl iranl added the enhancement New feature or request label May 19, 2024
@iranl iranl self-assigned this May 19, 2024
@technyon technyon merged commit aa72157 into technyon:master May 22, 2024
2 checks passed
@iranl iranl deleted the update-wifimanager branch May 22, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AP Selection with Nuki Hub?
4 participants